package com.example.user.http

class HhResultHandler<T>() {
    private var success:((T) -> Unit)? = null
    private var failure:((Throwable) -> Unit)? = null

    infix fun onSuccess(block:(T) -> Unit){
        success = block
    }

    infix fun onFailure(block: (e: Throwable) -> Unit){
        failure = block
    }

    fun invokeSuccess(content: T){
        success?.invoke(content)
    }

    fun invokeFailure(throwable: Throwable){
        failure?.invoke(throwable)
    }
}